import { createSlice } from '@reduxjs/toolkit'
import { produce } from 'immer'

export type initialStateType = {
  openLeft: boolean
}

const initialState: initialStateType = {
  openLeft: true
}

export const layoutSlice = createSlice({
  name: 'layout',
  initialState,
  reducers: {
    toggleLeft: produce((state: initialStateType) => {
      // 切换左侧菜单栏的显示和隐藏
      state.openLeft = !state.openLeft
    })
  }
})
// 每个 case reducer 函数会生成对应的 Action creators
export const { toggleLeft } = layoutSlice.actions

export default layoutSlice.reducer
